#pragma once

#include "item_id.h"

namespace icache {

class cache;

class deinterlaced_item_id : public item_id
{
public: //item_id interface
	virtual bool equal(const item_id & i) const;
	virtual string name() const;
	virtual void serialize(std::ostream & o) const;
	virtual bool loadable() const;
	virtual void load(byte_image & im) const;
	virtual bool requestable() const;
	virtual void request() const;
	virtual bool cache_on_disc() const { return false; }
public:
	cache & my_cache; ///< this is both the cache for interlaced and deinterlaced frames
	item_id_sptr origin;
	bool upper_field; ///< the field that is taken from origin image without change (otherwise lower field)
	deinterlace_method method;
public:
	deinterlaced_item_id(cache & c, item_id_sptr const & o, bool uf, deinterlace_method m) : 
		my_cache(c), origin(o), upper_field(uf), method(m) { }
	static item_id_sptr create(cache & c, item_id_sptr const & o, bool uf, deinterlace_method m)
		{ return item_id_sptr(new deinterlaced_item_id(c, o, uf, m)); }
	item_id_sptr create_copy() const
		{ return item_id_sptr(new deinterlaced_item_id(my_cache, origin, upper_field, method)); }
	void deinterlace(byte_image const & interlaced, byte_image & dst) const;
	void deinterlace_in_place(byte_image & im) const;
};

} //namespace icache
